//Created by  for Jaws.Core.Web
//Original work Copyright(C) 2008.  All Rights Reserved.

namespace Jaws.Core.Web.Entities.Validation.CustomAttributes
{
    public class MaxLengthAttribute : ValidationAttribute
    {
        private int MaxLength { get; set; }

        public MaxLengthAttribute(int maxLength)
        {
            MaxLength = maxLength;
            Message = string.Format(ValidationMessages.MaxLength, maxLength);
        }
        
        #region Overrides of ValidationAttribute

        public override bool IsValid(object item)
        {
            return ((string)item).Length <= MaxLength;
        }

        #endregion
    }
}